﻿using UnityEngine;
using System.Collections;

public class CreateTexture {

    private static CreateTexture _instance;

    private CreateTexture() { }

    public static CreateTexture getInstance()
    {
        if(_instance == null)
            _instance = new CreateTexture();
        
        return _instance;
    }

    public GameObject getTexture(string name,Color color,float alpha)
    {
        GameObject obj = new GameObject();
        obj.name = "Fade In";
        obj.AddComponent("GUITexture");

        obj.guiTexture.pixelInset = new Rect(0,0,Screen.width,Screen.height);

        Texture2D texture = new Texture2D(1,1);
		texture.SetPixels(new Color[1] {color});
		texture.Apply();

        obj.guiTexture.color = new Color(color.r, color.g, color.b, alpha);
        obj.guiTexture.texture = texture;

        return obj;
    }
}
